import configparser
import os.path
import requests
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from autotest.testsuites.demo_login import demoLoing

#读取配置文件
config = configparser.ConfigParser()
path=os.path.dirname(os.path.abspath('.'))+'/autotest/config/'
config.read(path+'config.ini',encoding='utf-8')
class test1:
    def __init__(self):
        #获取section节点
        print(config.sections())
        #获取指定section下的option值
        r=config.options("browserType")
        print(r)
        #获取option下的value
        value=config.get("browserType","browsername")
        value1=config['testServer']['URL']
        print(value)
        print(value1)

class test2:
    def __init__(self,uo,ue):
        # 插入图片
        start_key = 'screenshots:'
        end_key = '.png'
        unum = str(uo).rfind(start_key)
        print("unum:",unum)
        if ((uo or ue) and unum != -1):
            hidde_status = ''
            left = int(str(uo).rfind(start_key))
            right = int(str(uo).rfind(end_key))
            # img_name = str(str(uo)[left + len(start_key):left + right - left + len(end_key)]).replace('', '')
            img_name="20250918140140.png"
            print("img_name:",img_name)
            image_url = '../screenshots/{}'.format(img_name)
        else:
            hidde_status = '''hidden="hidden"'''
            image_url = ''

        print("hidde_status:",hidde_status)
        print("image_url:",image_url)

class test3:
    def __init__(self,uo):
        # text="hujienihao"
        # position=text.rfind("ni")
        start_key = 'ni'
        position=str(uo).rfind('ni')
        print("position:",position)
class test4:
    def __init__(self):
        #需要指定浏览器驱动地址
        # service=Service('C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe')
        service=Service(executable_path='C:\\Users\\w1447\\.cache\\selenium\\chromedriver\\win64\\139.0.7258.154\\chromedriver.exe')
        driver=webdriver.Chrome(service=service)
        try:
            ch=driver.capabilities['chrome']['chromeOptions'].split('')[0]
            print(f"当前使用的ChromeDriver 版本是:",ch)
            cha=driver.capabilities['browserVersion']
            print(f"当前Chrome浏览器版本是:{cha}")
        except:
            print("chromedriver error")
        finally:
            driver.close()

class test5:
    def __init__(self):
        url = "https://console.yjproject.chinamcloud.cn/login/lr/login/multi-tenant-login"
        data = {
              "group_code": "",
              "login_type": "mobile_password",
              "login_mode": 1,
              "ras_pwd": "BrMCKkjgX2jpKrYxGKH2rlSax/y5blRqnWvhugAyYxgprMYLIj6Boio0Hby7nqr1v2zgFcpdeq97sUXKaeh2zL5UGmWwfyrQL4jSEPILbKwZx7ReNfREnIG524iXzi1TfDUMcKWgx8an/+JVWHBh5BlJU5cjusxmu5/w4Bf63LE=",
              "captcha_drive": "false",
              "validate": "",
              "user_mobile": "19141013603"
            }
        res = requests.post(url=url,data=data)
        print(res.text)

if __name__ == '__main__':
    # test1=test1()
    # test2("123screenshots:21","123.png")
    # test3=test3("hujienihao")
    # test4=test4()
    test5=test5()